﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class header_uc_header_marquee : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LoadTracker();
            //lblMarquee.Attributes.Add("style", "float:left");
        }
    }

    private void LoadTracker()
    {
        int lang_id = DAO.Connection.DEFAULT_LANGUAGE;
        using (SqlConnection conn = new SqlConnection(DAO.Connection.CONN_STRING1))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand("SELECT * from Fn_GetTicker(@lang_id)", conn))
            {
                cmd.Parameters.Add(new SqlParameter("@lang_id", lang_id));
                SqlDataReader dr = cmd.ExecuteReader();
                phMarquee.Controls.Clear();
                if (dr != null)
                {
                    if (dr.Read())
                    {
                        string[] text = dr["text"].ToString().Split('*');
                        foreach (string s in text)
                        {
                            phMarquee.Controls.Add(new LiteralControl("<div style='float:left;width:10px'>&nbsp;</div><div class='headerInfo'>INFO</div><span style='float:left' class='ticker'>" + s + "</span><div class='headerInfo'>INFO</div>"));
                        }
                        //lblMarquee.Text = dr["text"].ToString();
                    }
                    else
                    {
                        //lblMarquee.Text = "";
                    }
                }
            }
        }
    }
}
